import { createRouter, createWebHashHistory } from 'vue-router'
// 实现路由组件的按需加载(按需加载的模式可以让路由单独打包成一个独立的文件，从而实现按需加载)
const Home = () => import('@/views/home/index')
const Login = () => import('@/views/login/index')
const Layout = () => import('@/views/layout/index')
const Goods = () => import('@/views/goods/index')
const LoginCallback = () => import('@/views/login/callback')
const routes = [
  {
    path: '/',
    component: Home,
    children: [
      { path: '', component: Layout },
      { path: 'product/:id', component: Goods }
    ]
  },
  { path: '/login', component: Login },
  { path: '/login/callback', component: LoginCallback }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
